import React from 'react';

import '@/assets/css/login.css'

const Login = () =>
{


    const login = async (values:any) => {
        var result:any = await React.HTTP.post('/business/login',values)

        if(result.code){
            React.UI.Toast.show({
                icon: 'success',
                content: result.msg,
                afterClose: () => {
                    React.Cookie.save('business',result.data)
                    React.navigate(result.url)
                    return false
                }
            })
        }else{
            React.UI.Toast.show({
                icon: 'fail',
                content: result.msg
            })
            return false
        }

    }

    return (
        <>
            
            <div className="login">
            <div className='title'><h1>登录</h1></div>
                <React.UI.Form
                    name='form'
                    onFinish={login}
                    footer={
                    <React.UI.Button block shape='rounded' type='submit' color='primary' size='large'>
                        登录
                    </React.UI.Button>
                    }
                >
                    <React.UI.Form.Item name='mobile' label='手机号' rules={[{ required: true },{pattern:/^1[3456789]\d{9}$/, message: '手机号格式不对'}]}>
                        <React.UI.Input placeholder='请输入手机号' />
                    </React.UI.Form.Item>

                    <React.UI.Form.Item name='password' label='密码' rules={[{ required: true }]}>
                        <React.UI.Input type='password' placeholder='请输入密码' />
                    </React.UI.Form.Item>

                </React.UI.Form>
                
                <div className='tips'>
                    <React.Router.Link to={'/business/password'}>
                        忘记密码
                    </React.Router.Link>

                    <React.Router.Link to={'/business/register'}>
                        前往注册
                    </React.Router.Link>
                </div>
            </div>
        </>
    )
}

export default Login